package org.example.condition;


import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class WindowsCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

        //获取环境变量
        Environment environment = context.getEnvironment();
        //在环境变量中获取系统
        String stu = environment.getProperty("OS");
        if (stu.contains("Windows")&&stu != null){
            return true;
        }
        return false;
    }
}
